package com.xzsoft.gdwz.controller;

import java.io.IOException;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;

import com.xzsoft.gdwz.schedual.JdOrderSchedualImpl;
import com.xzsoft.gdwz.schedual.SNOrderSchedualImpl;
import com.xzsoft.gdwz.services.RefreshTokenServices;
import com.xzsoft.gdwz.services.TokenServices;
import com.xzsoft.gdwz.util.MD5;

@Controller("tokenController")
@RequestMapping("/token")
public class TokenController {
	@Resource
	private TokenServices tokenServices;
	@Autowired
	private JdOrderSchedualImpl jdOrderSchedual;
	@Autowired
	private RefreshTokenServices refreshTokenServices;
	@Autowired
	private SNOrderSchedualImpl snOrderSchedual;
	
	@RequestMapping("/showToken")
	public String showToken(HttpServletRequest request,Model model,HttpServletResponse response) throws IOException{
		String sign = "1ZKMXxre3XVykhdHk0eL2016-07-14 17:56:00guodianb150b643d9ee49a283e919e55ac53e02ebe8ca8658a53d52ee4e1b620f1267b5access_token1ZKMXxre3XVykhdHk0eL";
		response.getWriter().println("before:"+sign);
		sign = MD5.GetMD5Code(sign).toUpperCase();
		response.getWriter().println("after:"+sign);
		response.getWriter().flush();
		response.getWriter().close();
		return null;
	}
	
	@RequestMapping("/refreshSnToken")
	public String refreshSnToken(){
		refreshTokenServices.refreshSnToken();
		return null;
	}
	
	@RequestMapping("/refreshToken")
	public String refreshDlToken(){
		refreshTokenServices.setXyToken();
//		refreshTokenServices.getXyToken();
		return null;
	}
	
	@RequestMapping("/getSnOrderInf")
	public String getSnOrderInf() throws Exception{
		snOrderSchedual.getOrderInf();
		return null;
	}
	
	@RequestMapping("/getJDOrderInfo")
	public String getJDOrderInfo() throws Exception{
		jdOrderSchedual.getOrderInf();
		return null;
	}
}
